package com.lq.java.proxy;

import java.lang.reflect.Proxy;

public class Test {

    public static void main(String[] args) throws Exception {
        Class<?> clazz = Class.forName("com.lq.java.proxy.HelloServiceImpl");
        Object implService = clazz.newInstance();
        // new Class[]{IHelloService.class} -> 该代理实现的接口列表(不是类或抽象类)
        //
        IHelloService helloService = (IHelloService)Proxy.newProxyInstance(IHelloService.class.getClassLoader(),
                implService.getClass().getInterfaces(),
                new MyProxy(implService));
        helloService.sayHello("张三");
    }
}
